<template>
  <div>
    <!-- 寄养单元 -->
    <div class="foster-cell" @click="goOrder(item.fid)">
      <div class="cover">
        <img :src="item.fosterCoverPic" alt="" class="cover-img" />
        <div class="score">
          <img src="../assets/icon/forst-icon2.png" alt="" class="score-img" />
          <span class="score-text">{{ item.fosterScore }}</span>
        </div>
      </div>
      <div class="content">
        <div class="line1">
          <div class="title">
            <span>{{ item.fosterName }}</span>
            <img src="../assets/icon/forst-icon1.png" alt="" />
          </div>
          <div class="city">{{ item.fosterCity }}</div>
        </div>
        <div class="line2">
          <div class="tags">
            <span :class="'tag'+ (index+1)" v-for="(tag,index) in tags" :key="index">{{ tag }}</span>
          </div>
          <div class="price">
            ￥<span>{{ item.fosterPrice }}</span
            >/天
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tags: [],
    };
  },
  props: ["item"],
  methods: {
    goOrder(fid) {
      this.$router.push(`/fosterorder?fid=${fid}`);
    },
  },
  mounted() {
    this.tags = this.item.fosterTags.split(",")
  },
};
</script>

<style lang="scss" scoped>
.foster-cell {
  width: 90vw;
  margin: auto;
  border-radius: 2vw;
  box-shadow: 0px 0px 6px #ccc;
  margin-bottom: 4vw;
  .cover {
    width: 90vw;
    height: 45vw;
    overflow: hidden;
    position: relative;
    .cover-img {
      width: 100%;
      border-radius: 2vw;
    }
    .score {
      position: absolute;
      top: 3vw;
      left: 3vw;
      background-color: #fff;
      border-radius: 1.5vw;
      padding: 1vw 2vw;
      line-height: 6vw;
      .score-img {
        width: 4vw;
        margin-right: 0.6vw;
      }
      .score-text {
        font-size: 0.9rem;
        font-weight: bold;
        vertical-align: middle;
      }
    }
  }
  .content {
    width: 90%;
    margin: auto;
    padding-bottom: 4vw;
    .line1 {
      display: flex;
      justify-content: space-between;
      margin: 4vw 0;
      height: 6vw;
      line-height: 6vw;
      .title {
        span {
          font-weight: bold;
          font-size: 1rem;
          margin-right: 1vw;
        }
        img {
          width: 4vw;
          margin-bottom: 3px;
        }
      }
      .city {
        font-size: 0.7rem;
        color: #a7a7a7;
      }
    }
    .line2 {
      display: flex;
      justify-content: space-between;
      font-size: 0.8rem;
      height: 6vw;
      line-height: 6vw;
      .tags {
        .tag1 {
          background-color: #efedfd;
          color: #8d73ec;
          padding: 1vw 2vw;
          border-radius: 1vw;
          margin-right: 2vw;
        }
        .tag2 {
          background-color: #edf5fd;
          color: #68badd;
          padding: 1vw 2vw;
          border-radius: 1vw;
          margin-right: 2vw;
        }
        .tag3 {
          background-color: #f2f2f2;
          color: #666;
          padding: 1vw 2vw;
          border-radius: 1vw;
          margin-right: 2vw;
        }
      }
      .price {
        color: #a7a7a7;
        height: 6vw;
        line-height: 6vw;
        span {
          color: #000;
          font-weight: bold;
          font-size: 0.9rem;
          vertical-align: middle;
        }
      }
    }
  }
}
</style>